package com.bilibili.interface1;

public class ClassDataInterlmpl2 implements ClassDatalnter{
    private Student[] students;

    public ClassDataInterlmpl2(Student students[]){
        this.students=students;
    }
    public ClassDataInterlmpl2(){}
    @Override
    public void printAllStudentInfos() {
        int n1 = 0 ;
        int n2 = 0 ;
        for(int i = 0 ; i < students.length ; i++){
            Student s = students[i];
            System.out.println(s.getName()+"\t"+s.getSex()+"\t"+s.getScore());
            if('男'==(students[i].getSex())){
                n1++;
            }
            else {
                n2++;
            }
        }
        System.out.println("男生人数："+n1);
        System.out.println("女生人数："+n2);
    }

    @Override
    public void printAverageScore() {
        double all = students[0].getScore() ;
        double max = students[0].getScore() ;
        double min = students[0].getScore() ;
        int n = 1;
        for(int i = 1 ; i < students.length ; i++){
            Student s = students[i];
            if(max < students[i].getScore()){
                max = students[i].getScore();
            }
             if(min > students[i].getScore()){
                min = students[i].getScore();
            }

                all+=s.getScore();
                n++;

        }
        double score = (all-max-min)/(n-2);
        System.out.println("平均分是"+score);
    }
}
